package activity;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;

import javax.jdo.annotations.IdentityType;

import javax.jdo.annotations.PersistenceCapable;

import javax.jdo.annotations.Persistent;

import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.users.User;

@PersistenceCapable(identityType = IdentityType.APPLICATION)

public class Activity_supply{

    @PrimaryKey

    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    //�۰ʽs�X

    private Long actID_s;
    @Persistent

    private User userName_s;
  
    @Persistent

    private String actContent_s;
    
   
    @Persistent

    private int actPoint_s;
    @Persistent

    private String actShop_s;
    
    
    @Persistent

    private String actName_s;
    
    @Persistent

    private String actEnd_s;
    
    @Persistent

    private Date actStart_s;
    
    @Persistent

    private String actShop_d;
    
    
    @Persistent

    private String actName_d;
    
    @Persistent

    private int actPoint_d;

    
    public Activity_supply(String actShop_s,int actPoint_s,String actName_s,String actEnd_s,Date actStart_s,String actContent_s,User userName_s,String actShop_d,String actName_d,int actPoint_d){
    	this.actShop_s=actShop_s;
    	this.actName_s=actName_s;
    	this.actPoint_s=actPoint_s;   	    	    	
    	this.actContent_s=actContent_s;
    	this.actStart_s=actStart_s;
    	this.actEnd_s=actEnd_s;
        this.userName_s=userName_s;
        this.actShop_d=actShop_d;
        this.actName_d=actName_d;
        this.actPoint_d=actPoint_d;
    }
    

	public Long getActID_s() {
		return actID_s;
	}

	
	public User getUserName_s() {
		return userName_s;
	}





	public void setUserName_s(User userName_s) {
		this.userName_s = userName_s;
	}





	public String getActContent_s() {
		return actContent_s;
	}





	public void setActContent_s(String actContent_s) {
		this.actContent_s = actContent_s;
	}





	public int getActPoint_s() {
		return actPoint_s;
	}





	public void setActPoint_s(int actPoint_s) {
		this.actPoint_s = actPoint_s;
	}





	public String getActShop_s() {
		return actShop_s;
	}





	public void setActShop_s(String actShop_s) {
		this.actShop_s = actShop_s;
	}





	public String getActName_s() {
		return actName_s;
	}





	public void setActName_s(String actName_s) {
		this.actName_s = actName_s;
	}





	public String getActEnd_s() {
		return actEnd_s;
	}





	public void setActEnd_s(String actEnd_s) {
		this.actEnd_s = actEnd_s;
	}





	public Date getActStart_s() {
		return actStart_s;
	}





	public void setActStart_s(Date actStart_s) {
		this.actStart_s = actStart_s;
	}


	/**
	 * @return the actShop_d
	 */
	public String getActShop_d() {
		return actShop_d;
	}


	/**
	 * @param actShop_d the actShop_d to set
	 */
	public void setActShop_d(String actShop_d) {
		this.actShop_d = actShop_d;
	}


	/**
	 * @return the actName_d
	 */
	public String getActName_d() {
		return actName_d;
	}


	/**
	 * @param actName_d the actName_d to set
	 */
	public void setActName_d(String actName_d) {
		this.actName_d = actName_d;
	}


	/**
	 * @return the actPoint_d
	 */
	public int getActPoint_d() {
		return actPoint_d;
	}


	/**
	 * @param actPoint_d the actPoint_d to set
	 */
	public void setActPoint_d(int actPoint_d) {
		this.actPoint_d = actPoint_d;
	}
    
	public boolean activitySearch(String keyWord) {
		//actName_s = "我是活動";
		String data = actName_s;
		int count = 0;
		boolean result = false;

		if (keyWord.length() == 1) {
			for (int i = 0; i < data.length(); i++) {
				if (keyWord.charAt(0) == data.charAt(i))
					result = true;
					// System.out.print("get result!");
					
			}
		}

		else if (keyWord.length() < data.length()) {
			for (int i = 0; i < data.length(); i++) {
				for (int j = 0; j < keyWord.length(); j++) {
					char a = data.charAt(i + j);
					char b = keyWord.charAt(j);
					if (a == b) {
						count++;
					} else if (count == keyWord.length()) {
						break;
					} else {
						count = 0;
						break;
					}
				}
			}
			if (count == keyWord.length())
				result = true;
				//System.out.print(count);
		}

		else if (keyWord.length() == data.length()) {
			if (keyWord.equals(data))
				result = true;
				// System.out.print("get result!");				
		}
		return result;
	}
	
}    
   